<template>
  <div :class="['subject-column-render']"
       :title="record.subject">
    <span v-if="isShowState"
          :class="stateClass"> </span>
    <span v-if="isShowImportantLevel"
          :class="importantClass"> </span>
    <span :class="[
        'grid_black',
        'subject-column-render-title',
        'titleText',
        { color_blue: record.proxy }
      ]"><span>{{ record.subject }}</span></span>
    <span v-if="record.hasAttsFlag"
          :class="[hasAttachmentsClass]"></span>
    <span v-if="isShowBodyType"
          :class="bodyTypeClass"></span>
    <span v-if="isShowCoverTimeIcon"
          :class="coverTimeIconClass"></span>
  </div>
</template>

<script>
  export default {
    name: 'SubjectColumnRender',
    props: {
      record: {
        type: Object,
        default: () => {}
      }
    },
    computed: {
      // 是否显示流程状态
      isShowState() {
        const { state } = this.record;
        return state != null && state != '' && state != '0' && state != '2';
      },
      stateClass() {
        const { state } = this.record;
        if (state != null && state != '' && state != '0' && state != '2') {
          return `icon-default xicon-process-color xicon-process-end `;
        } else {
          return '';
        }
      },
      // 是否显示重要程度
      isShowImportantLevel() {
        const { importantLevel } = this.record;
        return importantLevel && importantLevel != 1;
      },
      importantClass() {
        const { importantLevel } = this.record;
        if (importantLevel && importantLevel != 1) {
          return `icon-default xicon-important${importantLevel - 1} `;
        } else {
          return '';
        }
      },
      // 附件图标
      hasAttachmentsClass() {
        const { hasAttsFlag } = this.record;
        if (hasAttsFlag) {
          return 'icon-default xicon-affix-color xicon-affix';
        } else {
          return '';
        }
      },
      // 是否显示协同类型
      isShowBodyType() {
        const { bodyType } = this.record;
        const bodyTypeArr = ['10', '30', '90'];
        if (bodyType && !bodyTypeArr.includes(bodyType)) {
          return true;
        } else {
          return false;
        }
      },
      bodyTypeClass() {
        const icon16Office = {
          20: 'xicon-form-text-color xicon-form-text',
          41: 'xicon-word-color xicon-word',
          42: 'xicon-excel-color xicon-excel',
          43: 'xicon-wps-color xicon-wps',
          44: 'xicon-wps-color xicon-excel',
          45: 'xicon-pdf-color xicon-pdf',
          46: 'xicon-ofd-color xicon-ofd'
        };
        const { bodyType } = this.record;
        const bodyTypeArr = ['10', '30', '90'];
        if (bodyType && !bodyTypeArr.includes(bodyType)) {
          return `icon-default ${icon16Office[bodyType]}`;
        } else {
          return '';
        }
      },
      // 如果设置了处理期限(节点期限),添加超期图标
      isShowCoverTimeIcon() {
        return this.record.nodeDeadLineName != this.$i18n('common.default');
      },
      coverTimeIconClass() {
        if (this.record.nodeDeadLineName != this.$i18n('common.default')) {
          if (this.record.isCoverTime) {
            //超期图标
            return 'icon-default ico16 extended_red_16 node-dead-line-icon';
          } else {
            //未超期图标
            return 'icon-default ico16 extended_blue_16 node-dead-line-icon';
          }
        } else {
          return '';
        }
      }
    },
    created() {},
    methods: {}
  };
</script>

<style scoped lang="scss">
  .subject-column-render {
    width: 100%;
    height: 37px;
    line-height: 37px;
    position: relative;
    display: flex;
    // align-items: center;

    .subject-column-render-title {
      max-width: 100%;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .icon-default {
      font-weight: initial;
      vertical-align: middle;
    }

    .node-dead-line-icon {
      height: inherit;
      line-height: inherit;
      padding-top: 1px;
      flex: 0 0 auto;
    }

    .xicon-process-color {
      color: #449bc0;
    }

    .xicon-affix-color {
      color: #f4935c;
    }

    .xicon-important1,
    .xicon-important2,
    .xicon-important3,
    .xicon-important4 {
      color: #fb3a36;
    }

    .xicon-form-text-color {
      color: #67c13a;
    }
    .xicon-word-color {
      color: #377ef0;
    }
    .xicon-wps-color {
      color: #11b5d2;
    }
    .xicon-pdf-color {
      color: #ff4608;
    }
    .xicon-ofd-color {
      color: #157efb;
    }
    .xicon-excel-color {
      color: #56a03d;
    }
  }
</style>
